home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PsL Monthly 1993 December
/
PSL Monthly Shareware CD-ROM (December 1993).iso
/
prgmming
/
dos
/
c
/
xmsif.exe
/
XMSTEST.C
< prev
next >
Wrap
C/C++ Source or Header
|
1992-11-14
|
54KB
|
1,191 lines
/***************************************************************************
* xmstest.c *
* MODULE: XMSIF *
* OS: DOS *
* VERSION: 1.2 *
* DATE: 11/14/92 *
* *
* Copyright (c) 1992 James W. Birdsall. All Rights Reserved. *
* *
* Requires xmsif.h, testutil.h, and xmstest.h to compile. *
* Compiles under Borland C++ 2.0, Turbo C 2.0, MSC 6.00A, MSC/C++ 7.0. *
* *
* Regression test and example for XMSIF. *
* *
* This file is part one of the regression tester and example for XMSIF. *
* The other parts are named EMSTEST2.C and EMSTEST3.C. All three parts *
* must be compiled and linked together along with the appropriate XMSIF *
* library to produce the tester executable. This program compiles under *
* tiny, small, medium, compact, large, and huge models. *
* *
* To use this tester: in general, just run it. Depending on what XMS *
* driver you have, you may need to use the "-q" option. HIMEM.SYS does *
* not require this option; QEMM 5.1* does; I don't know about other XMS *
* drivers. If you haven't used it and should, or should use it and *
* haven't, the tester can detect this and will abort with a message *
* suggesting you do the opposite of whatever you did. For more detail on *
* what this option actually does, see below. The tester produces output *
* on stdout. It performs 70+ tests, depending on the exact configuration *
* of your system, and parts of it run quite fast. If you want to read *
* all the output, you should redirect the output to a file (but first *
* you should probably run it straight to get an idea of how long it *
* takes on your machine). If you just want to see whether the tests all *
* pass, just run it -- if a test fails, execution aborts immediately. *
* *
* Certain types of failure may cause XMSTEST to not deallocate memory *
* that it has allocated. This should only occur if the library itself is *
* malfunctioning (which should never happen to you, only to me!) or if *
* you are trying a different compiler or unsupported memory model and *
* the compiler and library are therefore not communicating properly. It *
* may also happen if you press control-break. *
* *
* *
* The actions XMSTEST takes may be broken down into two parts: EMB tests *
* and UMB tests. In the first part, it tests the XMM* functions which *
* operate on extended memory blocks (EMBs). In the second part, it tests *
* the UMB* functions which operate on upper memory blocks (UMBs). Before *
* doing any of this, it tries to initialize XMSIF, which checks for the *
* presence of an XMS driver, and aborts if there isn't one. Then it *
* starts the first part, performing various preliminary tests on EMBs. *
* If it determines that there isn't a large enough EMB free, it reports *
* this and skips the copying function tests (tests of _XMMcopy() and *
* _XMMicopy()), otherwise it performs the copying function tests. Then *
* it starts the second part by trying to determine whether your system *
* has UMBs. If it does not, it reports this fact and skips the rest of *
* the UMB tests. If it does, it performs the rest of the UMB tests. If *
* you see a message about "another broken system", that means that your *
* XMS driver's support of UMBs is somewhat flaky, and the workarounds *
* already built into XMSIF were unable to cover the problem. In this *
* case, it will perform the rest of the UMB tests but is unable to check *
* that the functions actually did anything -- i.e. it can check the *
* return code from the function, but cannot independently verify via *
* other functions that the desired effect was actually achieved. See the *
* XMSIF documentation for a description of problems seen in the UMB *
* support of various XMS drivers. *
* *
* The "-q" option covers for some unusual behavior observed in QEMM *
* 5.1* which may also occur in other XMS drivers which provide EMS *
* services as well. In QEMM's case, when extended memory is allocated, *
* the total amount of XMS still available is decreased by the allocation *
* size rounded up to the nearest _16K_ (the EMS page size) instead of to *
* the nearest 1K (the XMS minimum allocation unit). HIMEM.SYS does not *
* display this behavior. The "-q" option tells XMSTEST to expect a drop *
* of a multiple of 16K after an allocation instead of a multiple of 1K. *
* While XMSTEST can easily detect the difference, this option was added *
* so that XMSTEST would know which multiple was expected and could *
* detect incorrect drops more reliably. *
* *
* The "-w" option covers for some different unusual behavior observed *
* in DOS windows running under MS Windows 3.1 (it is not known whether *
* Windows 3.0 does the same thing). In this case, when extended memory *
* is allocated, the total amount of XMS still available is decreased by *
* the allocation size rounded up to the nearest _4K_ (the 803/486 memory *
* management page size). The "-w" option tells XMSTEST to expect a drop *
* of a multiple of 4K after an allocation instead of a multiple of 1K. *
* While XMSTEST can easily detect the difference, this option was added *
* so that XMSTEST would know which multiple was expected and could *
* detect incorrect drops more reliably. *
* *
* *
* Turbo C and older versions of Turbo C++ do not have the _fmemcmp() and *
* _fmemset() functions; I don't know about older versions of MSC. If *
* your compiler does not have these functions, define the symbol *
* NO_FFUNC and functions in this file will be used instead. *
* *
***************************************************************************/
/*
** system includes <>
*/
#include <stdio.h>
#include <stdlib.h>
#include <dos.h>
#include <string.h>
#include <ctype.h>
/*
** custom includes ""
*/
#include "xmsif.h"
#include "xmstest.h"
#include "testutil.h"
/*
** local #defines
*/
/*
** misc: copyright strings, version macros, etc.
*/
/*
** typedefs
*/
/*
** global variables
*/
int testno = 1; /* number of test currently being done */
char *gblmsg = ""; /* msg to be printed in test header */
int qflag = 0; /* running QEMM or not? */
int wflag = 0; /* running under Windows or not? */
/*
** static globals
*/
/*
** function prototypes
*/
/*
** fu